package httpResult

import (
	"net/http"

	"github.com/zeromicro/go-zero/rest/httpx"
)

//json 返回内容
type Resp struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}
//ErrJson 返回错误
func ErrJson(w http.ResponseWriter, err error) {
	resp := Resp{
		Code: http.StatusInternalServerError,
		Msg:  err.Error(),
		Data: nil,
	}
	httpx.WriteJson(w, http.StatusInternalServerError, resp)
}

//OkJson 返回成功
func OkJson(w http.ResponseWriter, data interface{}) {
	resp := Resp{
		Code: http.StatusOK,
		Msg:  "ok",
		Data: data,
	}
	httpx.WriteJson(w, http.StatusOK, resp)
}